package com.evil.application.pojo.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

/**
 * 序列号生成表
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@Data
@TableName(value = "evil_generate_sn")
public class GenerateSn implements Serializable {

    /**
     * 类型
     */
    @TableId(value = "type", type = IdType.AUTO)
    private String type;

    /**
     * 序列号
     */
    @TableField(value = "sn")
    private Long sn;

    /**
     * 前缀
     */
    @TableField(value = "`prefix`")
    private String prefix;

    /**
     * 后缀
     */
    @TableField(value = "suffix")
    private String suffix;

    /**
     * 最小长度（不足sn字符串前缀补0）
     */
    @TableField(value = "min_length")
    private Integer minLength;

    /**
     * 上次重置时间
     */
    @TableField(value = "reset_time")
    private Date resetTime;

    /**
     * 备注
     */
    @TableField(value = "remark")
    private String remark;

    public String getPrefix(boolean userPrefix) {
        return userPrefix ? prefix : "";
    }

    public String getSuffix(boolean userSuffix) {
        return userSuffix ? suffix : "";
    }

    private static final long serialVersionUID = 1L;

    public static final String COL_TYPE = "type";

    public static final String COL_SN = "sn";

    public static final String COL_PREFIX = "prefix";

    public static final String COL_SUFFIX = "suffix";

    public static final String COL_MIN_LENGTH = "min_length";

    public static final String COL_RESET_TIME = "reset_time";

    public static final String COL_REMARK = "remark";
}